/*
* 运输管理
* */

import 'package:center_beijing/api/component_api.dart';
import 'package:center_beijing/api/product_api.dart';
import 'package:center_beijing/common/QRScan.dart';
import 'package:center_beijing/common/custom_floatingAction_buttonLocation.dart';
import 'package:center_beijing/common/styles.dart';
import 'package:center_beijing/common/utils.dart';
import 'package:center_beijing/config/global_config.dart';
import 'package:center_beijing/config/routeConfig.dart';
import 'package:center_beijing/models/selectItem.dart';
import 'package:center_beijing/widgets/custom_input_widget.dart';
import 'package:center_beijing/widgets/custom_loading_widget.dart';
import 'package:center_beijing/widgets/custom_select_widget.dart';
import 'package:center_beijing/widgets/selectRow_widget.dart';
import 'package:center_beijing/widgets/textarea_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:left_scroll_actions/cupertinoLeftScroll.dart';
import 'package:left_scroll_actions/global/actionListener.dart';
import 'package:get/get.dart';

class TransportationManagement extends StatefulWidget {
  @override
  _TransportationManagementState createState() =>
      _TransportationManagementState();
}

class _TransportationManagementState extends State<TransportationManagement>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;
  CustomLoading loading = CustomLoading.withMessage('提交中...');

  final ScrollController scroll = ScrollController();

  final TextEditingController invoiceInput = TextEditingController(); //发货单号
  final TextEditingController customer = TextEditingController(); //客户名称
  final TextEditingController customerAddress = TextEditingController(); //客户地址
  final TextEditingController contacts = TextEditingController(); //联系人
  final TextEditingController contactPhone = TextEditingController(); //联系人电话
  final TextEditingController carNumber = TextEditingController(); //车牌号
  final TextEditingController tranPerson = TextEditingController(); //运输人
  final TextEditingController tranPhone = TextEditingController(); //联系电话

  List<SelectItems> projectNameList = [];
  SelectItems selectProject = SelectItems();
  var deliveryTime = ''; //发货时间
  List selectList = [];
  String remark = ''; //备注
  bool listHide = false;
  var code = Utils.getRandomCode(8);
  var carId = '';

  @override
  void initState() {
    _controller = AnimationController(vsync: this);
    super.initState();

    this.getOrders();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  /*
  * 获取订单列表
  * */
  getOrders() async {
    var pass = {'projectId': GlobalConfig.selectFactory.value};
    var result = await getOrderList(pass);
    loading.dismiss();
    if (result != null) {
      List<SelectItems> tem = [];
      result.forEach((item) {
        tem.add(SelectItems(
            label: item['orderName'], value: item['id'], dict: item));
      });
      this.setState(() {
        projectNameList = tem;
      });
    }
  }

  submit() async {
    if (deliveryTime == '') {
      Fluttertoast.showToast(msg: '请选择发货时间');
    } else if (selectProject.value == null) {
      Fluttertoast.showToast(msg: '请选择订单');
    } else if (invoiceInput.text == '') {
      Fluttertoast.showToast(msg: '请输入发货单号');
    } else if (carNumber.text == '') {
      Fluttertoast.showToast(msg: '请选择运输车辆');
    } else if (carNumber.text == '') {
      Fluttertoast.showToast(msg: '请选择运输车辆');
    } else if (selectList.length == 0) {
      Fluttertoast.showToast(msg: '请添加构件');
    } else {
      loading.show(delay: 30);
      var pass = {
        'compIds': selectList.map((e) {
          return e['id'];
        }).toList(),
        'viewTransportForm': {
          'projectId': GlobalConfig.selectFactory.value,
          'createMan': GlobalConfig.userInfo['name'],
          'systemSerial': code,
          'clientAddress': customerAddress.text,
          'clientName': customer.text,
          'linkMan': contacts.text,
          'linkManPhone': contactPhone.text,
          'orderName': selectProject.label,
          'planSendTime': DateTime.parse(deliveryTime).toIso8601String(),
          'sendNumber': invoiceInput.text,
          'transportCar': {
            'vehicleNum': carNumber.text,
            'transportPerson': tranPerson.text,
            'mobilePhone': tranPhone.text
          },
          'transportMask': this.remark,
          'transportState': 2
        },
      };
      var result = await transport(pass);
      loading.dismiss();
      if (result != null && result == '') {
        Fluttertoast.showToast(msg: '运输单提交成功');
        Get.back();
      }
    }
  }

  /*
  * 获取构件详情
  * */
  getCompDetail(compId) async {
    bool have = false;
    for (var i = 0; i < selectList.length; i++) {
      if (selectList[i]['id'] == compId) {
        have = true;
        break;
      }
    }
    if (!have) {
      var result = await getComponentDetail(compId);
      if (result != null) {
        if(result['state'].toString() == '3'){
          Fluttertoast.showToast(msg: '构件已经报废');
        }else if (result['processStatus'].toString() == '4') {
          if(result['orderInfo']['id']== selectProject.value){
            this.setState(() {
              selectList.add(result);
            });
          }else{
            Fluttertoast.showToast(msg: '构件不属于该订单!');
          }
        } else if (result['processStatus'] < 4) {
          Fluttertoast.showToast(msg: '构件还未入库');
        } else if (result['processStatus'] > 4) {
          Fluttertoast.showToast(msg: '构件已运输');
        }
      }
    }
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
        appBar: AppBar(
          title: Text('运输管理'),
        ),
        body: GestureDetector(
          onTap: () {
            FocusScope.of(context).requestFocus(FocusNode());
          },
          child: Container(
            color: Styles.MainBackgroundColor,
            padding: EdgeInsets.fromLTRB(
                0, 0, 0, MediaQuery.of(context).padding.bottom + 70),
            child: SingleChildScrollView(
              controller: scroll,
              child: Column(
                children: [
                  Container(
                    alignment: Alignment.centerLeft,
                    padding: EdgeInsets.fromLTRB(Styles.spacing16,
                        Styles.spacing12, Styles.spacing8, Styles.spacing8),
                    child: Text(
                      '订单信息',
                      style: TextStyle(
                          color: Styles.TitleColor,
                          fontSize: Styles.NormalFont),
                    ),
                  ),
                  Container(
                    color: Colors.white,
                    margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
                    child: CustomSelectWidget(
                      require: true,
                      rightText: selectProject.label != null
                          ? selectProject.label
                          : '请选择',
                      items: projectNameList,
                      selectCallback: (value) {
                        this.setState(() {
                          selectProject = value;
                          customer.text = value.dict['customerName'] != null
                              ? value.dict['customerName']
                              : '--';
                          contacts.text = value.dict['contactPerson'] != null
                              ? value.dict['contactPerson']
                              : '--';
                          contactPhone.text = value.dict['mobilePhone'] != null
                              ? value.dict['mobilePhone']
                              : '--';
                          customerAddress.text =
                          value.dict['customerAddress'] != null
                              ? value.dict['customerAddress']
                              : '--';
                          selectList = [];
                        });
                      },
                      title: '订单名称',
                    ),
                  ),
                  Container(
                    alignment: Alignment.centerLeft,
                    padding: EdgeInsets.fromLTRB(Styles.spacing16,
                        Styles.spacing12, Styles.spacing8, Styles.spacing8),
                    child: Text(
                      '运输单信息',
                      style: TextStyle(
                          color: Styles.TitleColor,
                          fontSize: Styles.NormalFont),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                    color: Colors.white,
                    padding: EdgeInsets.fromLTRB(Styles.spacing8, 0, 0, 0),
                    child: SelectRow(
                        titleFont: Styles.MiddleFont17,
                        require: true,
                        selectType: DateMode.YMD,
                        title: '发货时间',
                        rightText: deliveryTime,
                        selectCallback: (value) {
                          this.setState(() {
                            deliveryTime = value;
                          });
                        }),
                  ),
                  Container(
                    color: Colors.white,
                    margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                    padding: EdgeInsets.fromLTRB(
                        Styles.spacing8, 0, Styles.spacing8, 0),
                    child: TextAreaWidget(
                      labelText: '备注',
                      defaultValue: '',
                      placeholder: '请输入备注',
                      disabled: false,
                      required: false,
                      rows: 4,
                      onChange: (value) => this.setState(() {
                        remark = value;
                      }),
                    ),
                  ),

                  Container(
                    color: Colors.white,
                    margin: EdgeInsets.fromLTRB(
                        0, Styles.spacing8, 0, Styles.spacing8),
                    padding: EdgeInsets.fromLTRB(
                        Styles.spacing8, 0, Styles.spacing8, 0),
                    child: CustomInput(
                      inputformat: [LengthLimitingTextInputFormatter(25)],
                      title: '发货单号',
                      placeHold: '请输入',
                      textInput: this.invoiceInput,
                      clearAll: false,
                      require: true,
                    ),
                  ),
                  this.selectProject.label!=null?
                  Column(
                    children: [
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [LengthLimitingTextInputFormatter(50)],
                          title: '客户名称',
                          placeHold: '请输入',
                          textInput: this.customer,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [LengthLimitingTextInputFormatter(20)],
                          title: '联系人',
                          placeHold: '请输入',
                          textInput: this.contacts,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [
                            LengthLimitingTextInputFormatter(12),
                            WhitelistingTextInputFormatter(RegExp("[0-9\-]"))
                          ],
                          title: '联系电话',
                          placeHold: '请输入',
                          textInput: this.contactPhone,
                          keyboardType: TextInputType.phone,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [LengthLimitingTextInputFormatter(50)],
                          title: '客户地址',
                          placeHold: '请输入',
                          textInput: this.customerAddress,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                    ],
                  ):Container(),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [

                      Container(
                        alignment: Alignment.centerLeft,
                        padding: EdgeInsets.fromLTRB(Styles.spacing16,
                            Styles.spacing12, Styles.spacing8, Styles.spacing8),
                        child: RichText(
                            text: TextSpan(children: [
                              TextSpan(
                                text: '*',
                                style: TextStyle(
                                    fontSize: Styles.NormalFont, color: Styles.RedColor),
                              ),
                              TextSpan(
                                text: "承运信息",
                                style: TextStyle(
                                    fontSize: Styles.NormalFont,
                                    color: Styles.DetailColor),
                              ),

                            ])),
                      ),
                      Container(
                        padding: EdgeInsets.fromLTRB(Styles.spacing16,
                            Styles.spacing8, Styles.spacing16, Styles.spacing4),
                        child: GestureDetector(
                          onTap: () async {
                            var data = await Get.toNamed(RouteConfig.selectCar);
                            print(data);
                            if (data != null) {
                              this.setState(() {
                                carNumber.text = data['vehicleNum'];
                                tranPerson.text = data['transportPerson'];
                                tranPhone.text = data['mobilePhone'];
                                carId = data['id'];
                              });
                            }
                          },
                          child: Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing8,
                                Styles.spacing8,
                                Styles.spacing8,
                                Styles.spacing8),
                            decoration: BoxDecoration(
                                gradient: LinearGradient(
                                  colors: [
                                    Colors.blue,
                                    Styles.BlueColor,
                                  ],
                                ),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(4.0.r))),
                            child: Text(
                              '选择运输车辆',
                              style: TextStyle(
                                  color: Styles.ShareWhite,
                                  fontSize: Styles.NormalFont),
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                  carNumber.text!=''?Column(
                    children: [
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [LengthLimitingTextInputFormatter(20)],
                          title: '车牌号',
                          placeHold: '请选择',
                          textInput: this.carNumber,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [LengthLimitingTextInputFormatter(20)],
                          title: '运输人',
                          placeHold: '请选择',
                          textInput: this.tranPerson,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                      Container(
                        color: Colors.white,
                        margin: EdgeInsets.fromLTRB(0, Styles.spacing8, 0, 0),
                        padding: EdgeInsets.fromLTRB(
                            Styles.spacing8, 0, Styles.spacing8, 0),
                        child: CustomInput(
                          inputformat: [LengthLimitingTextInputFormatter(20)],
                          title: '联系电话',
                          placeHold: '请选择',
                          keyboardType: TextInputType.number,
                          textInput: this.tranPhone,
                          clearAll: false,
                          require: false,
                          readOnly: true,
                        ),
                      ),
                    ],
                  ):Container(),

                  Container(
                    alignment: Alignment.centerLeft,
                    padding: EdgeInsets.fromLTRB(Styles.spacing16,
                        Styles.spacing12, Styles.spacing8, Styles.spacing8),
                    child: Text(
                      '构件信息',
                      style: TextStyle(
                          color: Styles.TitleColor,
                          fontSize: Styles.NormalFont),
                    ),
                  ),
                  Container(
                    color: Colors.white,
                    padding: EdgeInsets.fromLTRB(Styles.spacing8,
                        Styles.spacing8, Styles.spacing8, Styles.spacing8),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            RichText(
                                text: TextSpan(children: [
                                  TextSpan(
                                      text: '已选构件（',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont)),
                                  TextSpan(
                                      text: selectList.length.toString(),
                                      style: TextStyle(
                                          color: Styles.BlueColor,
                                          fontSize: Styles.NormalFont)),
                                  TextSpan(
                                      text: '）',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.NormalFont)),
                                ])),
                            GestureDetector(
                              onTap: () {
                                print('点击');
                                this.setState(() {
                                  listHide = !listHide;
                                  Future.delayed(Duration(milliseconds: 100), (){
                                    scroll.animateTo(
                                      scroll.position.maxScrollExtent,//滚动到底部
                                      duration: const Duration(milliseconds: 200),
                                      curve: Curves.easeOut,
                                    );
                                  });

                                });

                              },
                              child: Container(
                                padding: EdgeInsets.fromLTRB(
                                    Styles.spacing4, 0, 0, 0),
                                child: Text(
                                  '查看',
                                  style: TextStyle(
                                      color: Styles.BlueColor,
                                      fontSize: Styles.NormalFont),
                                ),
                              ),
                            )
                          ],
                        ),
                        Expanded(
                          child: Container(
                            padding: EdgeInsets.fromLTRB(
                                Styles.spacing16, 0, Styles.spacing16, 0),
                            margin: EdgeInsets.fromLTRB(
                                0, Styles.spacing8, 0, Styles.spacing8),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    onTap: () async {
                                      if(selectProject.value!=null){
                                        var result = await Get.toNamed(
                                            RouteConfig.selectComponentTran,arguments: {'selectList':selectList,'type':'4','orderId':selectProject.value});
                                        if (result != null) {
                                          this.setState(() {
                                            selectList = result;
                                            listHide = false;
                                            Future.delayed(Duration(milliseconds: 100), (){
                                              scroll.animateTo(
                                                scroll.position.maxScrollExtent,//滚动到底部
                                                duration: const Duration(milliseconds: 200),
                                                curve: Curves.easeOut,
                                              );
                                            });
                                          });
                                        }
                                      }else{
                                        Fluttertoast.showToast(msg: '请先选择订单');
                                      }

                                    },
                                    child: Container(
                                      alignment: Alignment.center,
                                      padding: EdgeInsets.fromLTRB(
                                          Styles.spacing16,
                                          Styles.spacing8,
                                          Styles.spacing16,
                                          Styles.spacing8),
                                      decoration: BoxDecoration(
                                          color: Styles.GrayLight,
                                          border: Border.all(
                                              color: Styles.LineColor,
                                              width: 1),
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(4.0.r))),
                                      child: Text(
                                        '搜索构件',
                                        style: TextStyle(
                                            color: Styles.LeftTitleColor,
                                            fontSize: Styles.NormalFont),
                                      ),
                                    ),
                                  ),
                                ),
                                GestureDetector(
                                  onTap: () async {
                                    if(selectProject.value!=null){
                                      var result = await QrScan.scan(context);
                                      if (result != null) {
                                        if (result['type'] == 1) {
                                          this.getCompDetail(result['code']);
                                        } else {
                                          showDialog(
                                              barrierDismissible: false,
                                              context: context,
                                              builder: (BuildContext context) {
                                                return AlertDialog(
                                                  title: Text('注意'),
                                                  content: Text('请扫描构件二维码！'),
                                                  actions: <Widget>[
                                                    new Container(
                                                      child: FlatButton(
                                                        child: new Text(
                                                          "确定",
                                                          style: TextStyle(color: Colors.red),
                                                        ),
                                                        onPressed: () {
                                                          Navigator.pop(context);
                                                        },
                                                      ),
                                                    ),

                                                  ],
                                                );
                                              });
                                        }
                                      }
                                    }else{
                                      Fluttertoast.showToast(msg: '请先选择订单');
                                    }

                                  },
                                  child: Container(
                                    color: Styles.BlueColor,
                                    padding: EdgeInsets.fromLTRB(
                                        Styles.spacing8,
                                        Styles.spacing8,
                                        Styles.spacing8,
                                        Styles.spacing8),
                                    margin:
                                    EdgeInsets.only(left: Styles.spacing16),
                                    child: Image.asset(
                                      'assets/images/scan.png',
                                      width: 20.w,
                                      height: 20.h,
                                      fit: BoxFit.contain,
                                      color: Colors.white,
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  !listHide
                      ? Column(
                    children: this.selectList.map((item) {
                      return CupertinoLeftScroll(
                        // important, each Row must have different key.
                        // DO NOT use '$index' as Key! Use id or title.
                        key: Key(item.toString()),
                        // left scroll widget will auto close while the other widget is opened and has same closeTag.
                        // 当另一个有相同closeTag的组件打开时，其他有着相同closeTag的组件会自动关闭.
                        closeTag: LeftScrollCloseTag(item.toString()),
                        buttonWidth: 80,
                        child: Container(
                          color: Colors.white,
                          padding: EdgeInsets.fromLTRB(
                              Styles.spacing8,
                              Styles.spacing8,
                              Styles.spacing8,
                              Styles.spacing8),
                          margin: EdgeInsets.only(top: Styles.spacing8),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Row(
                                children: [
                                  Container(
                                    margin: EdgeInsets.only(
                                        right: Styles.spacing8),
                                    height: 20.h,
                                    width: 4.w,
                                    color: Styles.BlueColor,
                                  ),
                                  Text(
                                    (item['compKind'] != null &&
                                        item['compKind']
                                        ['compKindName'] !=
                                            null)
                                        ? item['compKind']['compKindName']
                                        : '--',
                                    style: TextStyle(
                                        color: Styles.DetailColor,
                                        fontSize: Styles.Middle16Font),
                                  ),
                                ],
                              ),
                              Container(
                                margin: EdgeInsets.fromLTRB(
                                    Styles.spacing8,
                                    0,
                                    Styles.spacing8,
                                    0),
                                child: Column(
                                  crossAxisAlignment:
                                  CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      item['code'] != null
                                          ? item['code']
                                          : '--',
                                      style: TextStyle(
                                          color: Styles.DetailColor,
                                          fontSize: Styles.Middle16Font),
                                    ),
                                    Text(
                                      (item['orderInfo'] != null &&
                                          item['orderInfo']
                                          ['orderName'] !=
                                              null)
                                          ? item['orderInfo']['orderName']
                                          : '--',
                                      style: TextStyle(
                                          color: Styles.LeftTitleColor,
                                          fontSize: Styles.NormalFont),
                                    ),
                                    Text(
                                      item['levelPath'] != null
                                          ? (item['levelPath']
                                          .split('&_&_&'))
                                          .join('-')
                                          : '--',
                                      style: TextStyle(
                                          color: Styles.LeftTitleColor,
                                          fontSize: Styles.NormalFont),
                                    ),
                                  ],
                                ),
                              )
                            ],
                          ),
                        ),
                        buttons: <Widget>[
                          GestureDetector(
                            onTap: () {
                              this.setState(() {
                                selectList.remove(item);
                              });
                              print('删除');
                            },
                            child: Container(
                              margin: EdgeInsets.fromLTRB(
                                  0, 0, Styles.spacing16, 0),
                              decoration: BoxDecoration(
                                color: Styles.RedColor,
                                borderRadius: BorderRadius.all(
                                    Radius.circular(14.0.r)),
                              ),
                              alignment: Alignment.center,
                              child: Column(
                                mainAxisAlignment:
                                MainAxisAlignment.center,
                                children: [
                                  Image(
                                    image: AssetImage(
                                        'assets/images/delete.png'),
                                    width: 16.w,
                                    height: 16.w,
                                    fit: BoxFit.contain,
                                  ),
                                  Text(
                                    '删除',
                                    style: TextStyle(
                                        color: Colors.white,
                                        fontSize: Styles.NormalFont),
                                  )
                                ],
                              ),
                            ),
                          ),
                        ],
                        onTap: () {
                          print('tap row');
                        },
                      );
                    }).toList(),
                  )
                      : Container(),
                ],
              ),
            ),
          ),
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        floatingActionButtonAnimator: NoScalingAnimation(),
        floatingActionButton: Container(
          padding: EdgeInsets.fromLTRB(
              Styles.spacing8, Styles.spacing8, Styles.spacing8, 10),
          child: Container(
            decoration: new BoxDecoration(
              //背景
              color: Styles.BlueColor,
              //设置四周圆角 角度
              borderRadius: BorderRadius.all(Radius.circular(12.0)),
            ),
            child: FlatButton(
              disabledColor: Styles.SelectColor,
              onPressed: () {
                FocusScope.of(context).requestFocus(new FocusNode());
                showDialog(
                    barrierDismissible: false,
                    context: this.context,
                    builder: (BuildContext context) {
                      return AlertDialog(
                        title: Text('注意'),
                        content: Text('确认提交吗？'),
                        actions: <Widget>[
                          new Container(
                            child: FlatButton(
                              child: new Text(
                                "取消",
                                style: TextStyle(color: Colors.black),
                              ),
                              onPressed: () {
                                Navigator.pop(context);
                              },
                            ),
                          ),
                          new Container(
                            child: FlatButton(
                              child: new Text(
                                "确定",
                                style: TextStyle(color: Colors.red),
                              ),
                              onPressed: () {
                                Navigator.pop(context);
                                this.submit();
                              },
                            ),
                          ),
                        ],
                      );
                    });
              },
              child: Container(
                height: Styles.MainButtonHeight,
                alignment: Alignment.center,
                child: Text(
                  '确定提交',
                  style: TextStyle(
                      fontSize: Styles.MainButtonTextFont, color: Colors.white),
                ),
              ),
            ),
          ),
        ));
  }
}
